package com.dyh.quickdemozwei.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

@RestController
public class MainRouteController {

//    @RequestMapping({"/main_route/**"})
//    @RequestMapping(value = "/main_route/**")
//    public Object route(HttpServletRequest httpServletRequest, @RequestBody JSONObject jo){
//
//        //httpServletRequest.getRequestURI().substring(11)
//        String requestURI = httpServletRequest.getRequestURI();
//        ///main_route/sync/xzy
//        System.out.println(requestURI);
//
//        jo.put("mark",114514);
//        return jo;
//    }


    @RequestMapping(value = "/main_route/**")
    public Object main_route(HttpServletRequest httpServletRequest) throws IOException {

        InputStream in = httpServletRequest.getInputStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
        String content = IOUtils.toString(reader);


        System.out.println(content);



        return 114514;
    }


}
